//用户管理-用户列表
App.util.ns('Admin.User.User');
App.pages.add((function(){
    var NS = Admin.User.User;
    var page = new App.Page({
        name: 'user/user/index'
    });
    //页面初始化
    page.initStack.add('dataTable', function(){
        //面包屑导航
        this.setBreadcrumb([{
            icon: '<i class="fa fa-user"></i>',
            content: '用户管理'
        }, {
            content: '用户列表'
        }]);
        this.dataTable = new App.DataTable({
            baseUrl: '/admin/user/user',
            dataUrl: 'lists',
            table: {
                id: 'id',
                main: 0,
                columns: App.util.copy(NS.Conf.columns)
            },
            filter: [
                {type: 'keywords'},
                {type: 'timeRange'},
                {type: 'select', name: 'deposit_status', title: '押金状态', width: '80px', items: [
                    [0, '未交'],
                    [1, '已交']
                ]},
                {type: 'select', name: 'status', title: '状态', width: '80px', items: [
                    [1, '正常'],
                    [2, '禁用']
                ]},
                {type: 'select', name: 'enterprise_id', title: '企业', width: '120px',
                    items: App.models.get('enterprise-all'),
                    item_key: 'id',
                    item_name: 'name'
                }
            ],
            menu: [
                //{parent: 'add', permission: 'op:admin.user.user.create'},
                {parent: 'view', permission: 'op:admin.user.user.detail'},
                {parent: 'edit', permission: 'op:admin.user.user.update'},
                {type: 'inline', permission: 'op:admin.user.user.open', name: '开启', operation: {type: 'change', url: 'open'}, conditions: [['status', '2']]},
                {type: 'inline', permission: 'op:admin.user.user.close', name: '禁用', operation: {type: 'change', url: 'close'}, conditions: [['status', '1']]},
                {parent: 'drop', permission: 'op:admin.user.user.delete'},
                {type: 'multi', name: '状态', openable: true, items: [
                    {type: 'multi', permission: 'op:admin.user.user.multiOpen', name: '开启', operation: {type: 'change', url: 'multiOpen', confirm: true}},
                    {type: 'multi', permission: 'op:admin.user.user.multiClose', name: '禁用', operation: {type: 'change', url: 'multiClose', confirm: true}}
                    ], permission:[
                        'op:admin.user.user.multiOpen',
                        'op:admin.user.user.multiClose'
                ]},
                {parent: 'multiDrop', permission: 'op:admin.user.user.multiDelete'},
                {parent: 'oplog', permission: 'op:admin.user.user.getOpLogs'}
            ],
            detail: {
                form: {
                    items: App.util.copy(NS.Conf.form)
                }
            }
        }, page);
        this.dataTable.fix(this.contentContainer);
        this.dataTable.loadData();
    });
    //页面刷新
    page.refreshStack.add('dataTable', function(){
        this.dataTable.loadData(true);
    });
    //页面销毁
    page.destroyStack.add('dataTable', function(){
        this.dataTable.destroy();
    });
    return page;
})());